﻿

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Runtime.Serialization;

namespace WCFHost
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 

            using (ServiceHost host = new ServiceHost(typeof(WCFService.TeacherService)))
            {
                if (host.State != CommunicationState.Opened)
                {
                    host.Open();
                }

                foreach (var endpoint in host.Description.Endpoints)
                {
                    Console.WriteLine("契约：" + endpoint.Contract.Name + "\t绑定：" + endpoint.Binding.Name + "\t地址：" + endpoint.Address);
                }

                using (ServiceHost sspcHost = new ServiceHost(typeof(WCFService.StudentServicePerCall)))
                {
                    if (sspcHost.State != CommunicationState.Opened)
                    {
                        sspcHost.Open();
                    }

                    foreach (var endpoint in sspcHost.Description.Endpoints)
                    {
                        Console.WriteLine("契约：" + endpoint.Contract.Name + "\t绑定：" + endpoint.Binding.Name + "\t地址：" + endpoint.Address);
                    }
                    using (ServiceHost sspsHost = new ServiceHost(typeof(WCFService.StudentServicePerSession)))
                    {
                        if (sspsHost.State != CommunicationState.Opened)
                        {
                            sspsHost.Open();
                        }

                        foreach (var endpoint in sspsHost.Description.Endpoints)
                        {
                            Console.WriteLine("契约：" + endpoint.Contract.Name + "\t绑定：" + endpoint.Binding.Name + "\t地址：" + endpoint.Address);
                        }
                        using (ServiceHost ssps1Host = new ServiceHost(typeof(WCFService.StudentServicePerSingle)))
                        {
                            if (ssps1Host.State != CommunicationState.Opened)
                            {
                                ssps1Host.Open();
                            }

                            foreach (var endpoint in ssps1Host.Description.Endpoints)
                            {
                                Console.WriteLine("契约：" + endpoint.Contract.Name + "\t绑定：" + endpoint.Binding.Name + "\t地址：" + endpoint.Address);
                            }
                            Console.Read();
                        }
                    }
                }
                Console.Read();
            }


            #endregion
        }
    }
}
